package com.example.test622.ui.home

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.alibaba.android.arouter.launcher.ARouter
import com.example.net.entity.VideoTypeEntity

class TabAdapter(val data:MutableList<VideoTypeEntity> = mutableListOf(), private val f:Fragment):FragmentStateAdapter(f){
	override fun getItemCount(): Int  = data.size
	override fun createFragment(position: Int): Fragment  =
		ARouter.getInstance()
			.build("/home/video")
			.withString("channelid",data[position].channelid)
			.navigation() as Fragment
	fun getTitle(position: Int) = data[position].typename
	operator fun plusAssign(list:List<VideoTypeEntity>){
		val size = data.size
		data+=list
		notifyItemRangeInserted(size,list.size)
		notifyDataSetChanged()
	}
}